package com.zhongcw.test.java.reflect.reflect;

import com.zhongcw.test.java.reflect.pojo.Student;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectStudent {

    static String classReference = "com.zhongcw.test.java.reflect.pojo.Student";

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {

        //
        Class classs = Class.forName(classReference);

        //
        Constructor constructor = classs.getConstructor(String.class);

        //
        Student student = (Student) constructor.newInstance("钟长文");

        //
        student.sayHello();

    }
}